home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / envset10.zip / ENVSET.C next >
C/C++ Source or Header  |  1989-08-25  |  2KB  |  49 lines

  1.  
  2. /* TURBO C source code for envset.com.*/
  3.  
  4. /*                           Version 1.0                         */
  5. /*                           August, 1989                        */
  6. /*                        (c) 1989 John Sloan.                   */
  7.  
  8. /*                (John Sloan, Compuserve 73727,2162)            */
  9.  
  10. #include <stdio.h>
  11. #include <string.h>
  12. main( int argc, char *argv[] )
  13. {
  14.  
  15.     char *a;              /* this string will contain the DOS
  16.                              SET command string. */
  17.  
  18.     char *b;              /* the "b" variable will be the value that
  19.                              the environment variable is set to. */
  20.  
  21.     FILE *c;              /* this will be a file pointer to
  22.                              a temporary batch file that will
  23.                              contain the DOS "SET" command
  24.                              required to make the chosen
  25.                              variable available to the batch
  26.                              file. */
  27.  
  28.  
  29.     c=fopen(argv[1],"w"); /* open the temporary batch file. */
  30.  
  31.     gets(b);              /* get the input from the console... */
  32.  
  33.     strcpy(a,"set ");     /* copy "SET " to the SET command string. */
  34.  
  35.     strcat(a,argv[2]);    /* copy the temporary environment variable
  36.                              name to the SET command input string. */
  37.  
  38.     strcat(a,"=");        /* append an equals sign to the SET command
  39.                              string. */
  40.  
  41.     strcat(a,b);          /* append the input to the SET command string. */
  42.  
  43.     fputs(a,c);           /* Put the DOS SET command in the temporary batch
  44.                              file. */
  45.  
  46.     flushall();           /* Flush the temporary batch file. */
  47.     fclose(c);            /* Close the temporary batch file. */
  48. }
  49.